#pragma once
#include <map>
#include "SceneNode.h"
#include "../util/Shared_ptr.h"
#include "RootNode.h"
#include "Messenger.h"
#include "event/Event_FrameRendered.h"
#include "CameraNode.h"



namespace Boon
{
namespace Rendering
{
	class CameraNode;
	class Scene
	{
		typedef std::map<GameObjectID, ISceneNodeStrong> MapSceneNodesPerGOID;

	public:
		Scene(void);
		~Scene(void);

		bool				OnRender();
		bool				OnRestore();
		bool				OnLostDevice();
		bool				Update();
		bool				AddNode( GameObjectID id, const ISceneNodeStrong& child );
		bool				RemoveNode( GameObjectID id );
		void				SetCamera( const Shared_ptr<CameraNode>& camera );
		ISceneNodeWeak		GetNode( GameObjectID id );
		void				ParentNode( const ISceneNodeStrong& child, const ISceneNodeStrong& parent );
	private:

		void				Init();
		void				Unload();
		void				OnNodePositionUpdate( const IMessengerEventStrong& edata );
		void				OnCreatedRenderComponent( const IMessengerEventStrong& e );
		void				OnAddNewSceneNode( const IMessengerEventStrong& edata );

		RootNodeStrong					m_Root;
		CameraNodeStrong				m_Camera;
		ISceneNodeStrong				m_Renderer;
		MapSceneNodesPerGOID			m_SceneNodes;
		Messenger&						m_Messenger;
		Shared_ptr<Event_FrameRendered>	m_EventFrameRendered;

		friend class ProcessManager;
	};

}
}
